package com.own.component.common.base.entity.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.own.component.common.base.entity.po.BaseModifiedMemoPo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.FieldNameConstants;

import java.io.Serializable;

/**
 * BaseModifiedVo
 *
 * @author chenxueli
 * @date 2022-09-10 12:21:00
 */
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@FieldNameConstants
public class BaseModifiedMemoVo<T extends BaseModifiedMemoPo> extends BaseCreateVo<T> implements Serializable {

    @Schema(title = "备注")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String memo;

    /**
     * 构造方法
     *
     * @param entity 原对象
     */
    public BaseModifiedMemoVo(@NonNull T entity) {
        super(entity);
        this.memo = entity.getMemo();
    }

    /**
     * 转po对象
     *
     * @param entity 原
     * @return po对象
     */
    @Override
    public T toPo(T entity) {
        if (entity != null) {
            entity.setMemo(this.memo);
        }
        return super.toPo(entity);
    }

}
